$(document).ready(function() {

});


$(document).on('click', '#add-btn', function() {

    var stuNum=$("input[name='stuNum']").val();
    var punishType=$("textarea[name='punishType']").val();


    //封装成对象提交
    var data = {
        punishTime:new Date(),
        punishType:punishType,
        stuNum:stuNum,
        status:null,
    };

    $.ajax({
        url: "http://localhost:8080/punish/addPunish",
        type: "POST",
        async: false,
        data:JSON.stringify(data),
        dataType: "json",
        contentType:"application/json",
        success:function () {
            layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            layer.msg('操作成功！')
            setTimeout(function () {
                parent.location.reload()
            },1500);

        },
        error:function () {
            layer.alert("你的网络太慢了！添加失败!再试一次吧！");
        }
    });
});


